草庐IT

java - TypeScript:向枚举添加更多数据

全部标签

javascript - 类型 'number' 不可分配给类型 'Date' - Typescript 未编译

我有以下用于jquery计时器插件的代码。编译器给我错误:“类型‘数字’不可分配给类型‘日期’”$(function(){varnote=$('#note'),ts=newDate(2012,0,1),newYear=false;if((newDate())>ts){ts=(newDate()).getTime()+24*60*60*1000;//counting24hoursnewYear=false;}});});}; 最佳答案 您需要创建一个新的Date实例:if((newDate())>ts){ts=newDate((new

javascript - 使用 i18n 翻译 Angular 2 中的数据绑定(bind)文本

当我尝试使用i18n将英语翻译成法语时,按照https://angular.io/docs/ts/latest/cookbook/i18n.html上的国际化教程,一切正常。逐字逐句。但是当我尝试使用Angular2的数据绑定(bind)将可变文本插入HTML时,它停止工作了。这是我的HTML:{{value}}这是我的组件:import{Component}from'@angular/core';@Component({moduleId:module.id,selector:'my-app',templateUrl:'app.component.html'})exportclassA

javascript - 大数据集打破d3桑基图

我正在根据https://bl.ocks.org/d3noob/5028304中的示例制作d3Sankey图.此示例适用于较小的数据集。当我切换到使用更大的数据集时,可视化中断了。看起来问题在于dy值变为负值。在控制台中,错误是:Error:attributeheight:Anegativevalueisnotvalid.("-9.02557856272838")它指向的代码是:node.append("rect").attr("height",function(d){returnd.dy;})这可能是因为情节超出了屏幕?我看过使用d3比例尺,但我不确定如何实现它们。也许是这样的:d3

javascript - 添加提供程序@NgModule 时出现 Angular2 "No provider for Service!"错误

我有一个应用程序模块和单组件应用程序(用于演示我的问题),并出现以下错误:Errorin./AppComponentclassAppComponent_Host-inlinetemplate:0:0causedby:NoproviderforUserService!;Zone:;Task:Promise.then;Value:AppModule代码:import{NgModule}from'@angular/core';import{BrowserModule}from'@angular/platform-browser';import{UserService}from'./compo

javascript - 单击时如何从 Controller 获取数据到指令

当我使用ng-clicked时,我试图从Controller将数据发送到指令链接函数,但是我未能将数据发送到指令,该指令在页面加载时调用第一次这是我的html代码click这是我的Controller.controller('myController',function($scope){$scope.clickMe=function(somedata){$scope.myVal=somedata;};});我的指令.directive('myDirective',function(){return{restrict:'E',scope:{myKey:'='},templateUrl:'

javascript - jquery select2 : TypeError: b. 数据适配器为空

当使用select2多选并选择一个选项时,我收到此错误消息:TypeError:b.dataAdapterisnull有人知道这是怎么回事吗?多选工作正常,我只是想知道这条消息。编辑:这是我的html:Participant*这是jquery初始化:$(".select2me").select2({placeholder:"Select",width:"auto",allowClear:!0});如果在另一个下拉列表“projectSelector”中选择了一个值,我得到的多选数据:$('.projectSelector').on('change',function(){vartarg

javascript - 数据表标题在页面加载时不是全宽

当使用数据表加载我的Web应用程序页面时,数据表已加载但行不是表格的全宽。编辑数据或在数据表搜索中搜索后,标题跳到全Angular。看图片。对此有任何解决方案或解决方法吗?数据表截图:我的普通数据表很好,但这个是在模态中加载的。代码模式:×".$shop['Shop']."".$shop['Name']."".$shop['District']."";}?>我在页面页脚中使用的javascript://datatabletodisplayallselectedshopsondetailpageselectedshoptable=$('#DataListTableSelect

javascript - 使用指令将组件动态添加到子元素

尝试使用指令将组件动态放置到子元素。组件(作为模板):@Component({selector:'ps-tooltip',template:`{{content}}`})exportclassTooltipComponent{@Input()content:string;}指令:import{TooltipComponent}from'./tooltip.component';@Directive({selector:'[ps-tooltip]',})exportclassTooltipDirectiveimplementsAfterViewInit{@Input('ps-toolti

javascript - 第二个 .then() on promise 被调用时数据未定义

我在名为accountManager的服务中有一个函数返回如下所示的promise:这个promise上的.then()会触发并打印出预期的响应。signIn(email:String,password:String):Promise{returnthis.http.post('http://localhost:3000/api/signin',JSON.stringify({"email":email,"password":password}),{headers:this.headers}).toPromise().then(res=>{//**Thisisdefined**cons

javascript - TS1148 ~ 如何使用 --module : "import" and typescript 2. x "none"

我目前正在使用一些旧版JavaScript开发一个项目。该应用程序不包含模块加载器,它只是将所有内容作为全局变量放入window对象中。遗憾的是,接触遗留代码并包含模块加载器对我来说不是一个可行的选择。我想在我自己的代码中使用typescript。我设置了typescript编译器选项module:"none"在我的tsconfig.json中,我只使用命名空间来组织我自己的代码。到目前为止效果很好。..到现在为止:import*asRxfrom'rxjs';..Rx.Observable.from(['foo',bar']);...//ResultsinTypeScript-Erro